//
//  GovCenterIntroViewController.m
//  homeland
//
//  Created by SunShine on 14-1-18.
//  Copyright (c) 2014年 xzysun. All rights reserved.
//

#import "GovCenterIntroViewController.h"
#import "GovCenterFloorViewController.h"

@interface GovCenterIntroViewController ()

@property (strong, nonatomic) IBOutlet UIScrollView *scrollView;
@property (strong, nonatomic) IBOutlet UIView *infoPanel;
- (IBAction)phoneButtonAction:(id)sender;
- (IBAction)urlButtonAction:(id)sender;
@end

@implementation GovCenterIntroViewController

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    self.title = @"政务服务中心";
    self.navigationItem.rightBarButtonItem = rightNavBtnWithImgName(@"楼层分布", self, @selector(floorButtonAction:));
    [self.scrollView addSubview:self.infoPanel];
    self.scrollView.contentSize = self.infoPanel.frame.size;
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

#pragma mark - Buttons
-(void)floorButtonAction:(id)sender
{
    GovCenterFloorViewController *floorVC = [[GovCenterFloorViewController alloc] initWithNibName:@"GovCenterFloorViewController" bundle:nil];
    floorVC.hidesBottomBarWhenPushed = YES;
    [self.navigationController pushViewController:floorVC animated:YES];
}
- (IBAction)phoneButtonAction:(id)sender
{
    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"提示" message:@"您是否需要拨打电话:66662345" delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"确定", nil];
    alert.tag = PHONE_ALERT_TAG;
    [alert show];
}

- (IBAction)urlButtonAction:(id)sender
{
    [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"http://eg.haizhu.gov.cn/"]];
}

#pragma mark - Alert Delegate
-(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
    if (alertView.tag == PHONE_ALERT_TAG && buttonIndex == 1) {
        [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"tel://66662345"]];
    }
}
@end
